# 仿射变换
from showImg import *

# 读取图片
image=cv2.imread('train_image/book.png')   # 这里传入所需图片路径

# 输出图片的宽高
width,height = 500,600

pts1 = np.float32([[130,300],[520,100],[710,825],[1100,450]])
pts2 = np.float32([[0,0],[width,0],[0,height],[width,height]])


M = cv2.getPerspectiveTransform(pts1, pts2)
warped = cv2.warpPerspective(image, M, (width, height))


cv_show(warped,'warped',width, height)
cv2.imwrite("train_image/book_scale.png", warped)